package com.kokomi.config;

import org.springframework.amqp.core.Queue;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
    /**
     * 消息队列的配置类
     */
    @Configuration
    public class RabbitConfig {

        /**
         * 创建一个邮件队列
         */
        @Bean
        public Queue emailQueue() {
            return new Queue("email.queue");
        }

        /**
         * 创建清空购物车消息队列
         */
        @Bean
        public Queue clearCartQueue() {
            return new Queue("clear.cart.queue");
        }

        /**
         * 消息序列化成JSON字符串
         */
        @Bean
        public MessageConverter messageConverter() {
            return new Jackson2JsonMessageConverter();
        }
    }
